from multiprocessing import Pool
import time
def task(i):  # 进程任务
    time.sleep(2)
    return i+100
if __name__ == "__main__":
    stime = time.time()
    pool = Pool(5)
    for i in range(5):
        pool.apply(func=task,args=(i,))   # 添加同步进程
    pool.close()
    pool.join()  # 等待进程池中所有进程执行完毕
    etime = time.time()
    t = etime - stime
    print('the program time is :%s' % t)